const KEY="token";
const USERKEY="userInfo";

//保存token
export function setToken(data){
    if(!data) return;
    window.localStorage.setItem(KEY,data)
}
//获取token
export function getToken(){
    var token=window.localStorage.getItem(KEY);
    if(!token||token==="undefinde"||token===null){
        return null
    }else{
        return token
    }
}
//删除token
export function removeToken(){
    window.localStorage.removeItem(KEY);
}


//保存用户信息
export function setUser(data){
    if(!data) return;
    var info=JSON.stringify(data)
    window.localStorage.setItem(USERKEY,info)
}
//获取用户信息
export function getUser(){
    var user=window.localStorage.getItem(USERKEY);
    if(!user||user==="undefinde"||user===null){
        return null
    }else{
        return user
    }
}
//删除用户信息
export function removeUser(){
    window.localStorage.removeItem(USERKEY);
}

//清除全部信息
export function clearUser(){
    removeToken()
    removeUser()
}